package h0728;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 虚拟理财游戏
 * @date 2024/7/28 22:52
 */
public class InvestSequence {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //产品数目
        int totalMoney = sc.nextInt(); //总投资额
        int riskValue = sc.nextInt(); //总的可承受风险值
        int[] rates = new int[n]; //回报率
        int[] risks = new int[n];   //风险值序列
        int[] investments = new int[n]; //投资额度序列
        for (int i = 0; i < n; i++) {
            rates[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            risks[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            investments[i] = sc.nextInt();
        }

        int[] res=getRes(totalMoney, riskValue, rates, risks, investments);
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < res.length; i++) {
            builder.append(res[i]);
            if (i<res.length-1){
                builder.append(" ");
            }
        }
        System.out.println(builder);
    }

    private static int[] getRes(int totalMoney, int riskValue, int[] rates, int[] risks, int[] investments) {
        int n = rates.length;
        int[] ans=new int[n];//索引
        int sum = 0;
        int a,b = 0;

        for (int i = 0; i < n; i++) {
            if (risks[i] > riskValue ) continue; //如果单个产品不满足直接跳过此情况。
            //TODO 注意有可能总金额小于所有单个投资金额，所以这里要取最小值。
            int minned = Math.min(investments[i], totalMoney);
            a = minned * rates[i];

            if (a>sum){
                sum=a;
                ans=new int[n];
                ans[i]=minned;
            }
            int tempInvestJ = totalMoney - minned;

            for (int j = 0; j < n; j++) {
                if (i == j || risks[i] + risks[j] > riskValue){

                    continue; //如果超过总金额或者总风险,跳过
                }

                //如果j的投资金额大于减去i的剩下的投资金额，那么以tempInvestJ为准，不够就就以investments[j]为准
                if (investments[j]>tempInvestJ){
                     b=tempInvestJ*rates[j];
                }else {
                    b=investments[j]*rates[j];
                }

                if (a+b>sum){
                    sum=a+b;
                    ans=new int[n];
                    ans[i]=investments[i];
                    ans[j]=b/rates[j];
                }
            }
        }
        return ans;
    }
}
